<?php

$CLASS_QUERIES = new Queries($mysqli);
$items = $CLASS_QUERIES->get_items($table);

echo "<div class='content col-left form'>";
echo "<h1>View $table</h1>";
echo "<table>";

echo "<tr>";
foreach ($fields as $field) { //prints the header
    echo "<th>$field</th>";
}
if ($show_actions == 1) {
    echo "<th>Actions</th>";
}
echo "</tr>";

foreach ($items as $item) { //prints each item

    echo "<tr>";
    foreach ($fields as $field) {
        echo "<td>" . ((!is_null($item[$field])) ? $item[$field] : '-') . "</td>";
    }
    if ($show_edit == 1) {
        echo "<td><a href='#'>[edit]</a></td>";
    } elseif ($show_delete == 1) {
        echo "<td><a href='?action=del&id=" . $item["id_$table"] . "'>[delete]</a></td>";
    }
    echo "</tr>";
}

echo "</table>";

echo "</div>";
?>